//
//  NSString+md5string.m
//  md5Encryptiontesting
//
//  Created by srinath venkata on 01/10/13.
//  Copyright (c) 2013 Sridevi Technology Solutions. All rights reserved.
//

#import "NSString+md5string.h"
#import <CommonCrypto/CommonDigest.h>
@implementation NSString (md5string)
- (NSString *) encodeString:(NSString *) s {
    const char *cStr = [s UTF8String];
    unsigned char result[CC_MD5_DIGEST_LENGTH];
    CC_MD5(cStr, strlen(cStr), result);
    NSMutableString *result2 = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
    for(int i = 0; i < CC_MD5_DIGEST_LENGTH; ++i) {
        [result2 appendFormat:@"%02x", result[i]];
    }
    //NSLog(@"%@",result2);
    return [NSString stringWithString:result2];
}

@end
